import { ElLoading } from 'element-plus';
import { nextTick } from 'vue';
let loading: ReturnType<typeof ElLoading.service> | null = null;
export const startPageLoading = () => {
  if (!loading) {
    loading = ElLoading.service({
      lock: true,
      background: 'rgba(0,0,0,0.7)',
      text: '正在努力加载中......',
      target: 'body'
    });
  }
};

export const stopPageLoading = async () => {
  await nextTick(() => {
    if (loading) {
      loading.close();
      loading = null;
    }
  });
};
